    <%--
    Created by IntelliJ IDEA.
    User: DELL
    Date: 2021/4/1
    Time: 15:29
    To change this template use File | Settings | File Templates.
    --%>
        <%@ page contentType="text/html;charset=UTF-8" language="java" %>
        <html>

        <head>
        <meta charset="UTF-8">
        <title>新增</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js"
        charset="utf-8"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>

        </head>

        <body>
        <div class="x-body">
        <form class="layui-form">
        <div class="layui-form-item">
        <label for="name" class="layui-form-label">
        <span class="x-red">*</span>菜名
        </label>
        <div class="layui-input-inline">
        <input type="text" id="name" name="name"
                autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>请输入添加的菜名
        </div>
        </div>
        <div class="layui-form-item">
        <label for="icon" class="layui-form-label">
        <span class="x-red">*</span>图标名
        </label>
                <div class="layui-input-inline">
                <input type="text" id="icon" name="icon"
                autocomplete="off" class="layui-input">
                </div>
        <div class="layui-form-mid layui-word-aux">
        <span class="x-red">*</span>
        </div>
        </div>

        <div class="layui-form-item">
                <label for="price" class="layui-form-label">
                        <span class="x-red">*</span>价格
                </label>
        <div class="layui-input-inline">
                <input type="text" id="price" name="price"
                autocomplete="off" class="layui-input">
                </div>
                        <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                </div>
        </div>

        <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                <span class="x-red">*</span>类型
                </label>
        <div class="layui-input-inline">

        <select class="selected-inline" id="type" name="type">
                <option>主食</option>
                <option>甜点</option>
                <option>酒水</option>
        </select>
        </div>
                <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
                </div>
        </div>

        <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="" onclick="addMenu()">
                增加
                </button>
        </div>
        </form>
        </div>
        <script>
        function addMenu() {
                var name = $("#name").val();
                var icon = $("#icon").val();
                var price = $("#price").val();
                var type = $("#type").val();
                $.ajax({
                url:"${pageContext.request.contextPath}/menu/addAjax",
                type:"get",
                data:{"eName":name,"eIcon":icon,"ePrice":price,"eType":type},
                dataType:"json",
                 success:function(data) {
                if (data.info == "添加成功") {
                  alert("添加成功");
                        window.location.href = "${pageContext.request.contextPath}/menu/menu-add.jsp"
          }
                }
                })
        }



        </script>

        </body>

        </html>